<template>
  <div ref="chartRef" :style="{ height, width }"></div>
</template>
<script lang="ts" setup>
  import { onMounted, ref, Ref, PropType } from 'vue';
  import { useECharts } from '/@/hooks/web/useECharts';
  import { basicProps } from './props';
  import type { assetStateDataType } from '../api';

  const props = defineProps({
    ...basicProps,
    overviewData: {
      type: Object as PropType<assetStateDataType>,
      required: true,
    },
  });

  const chartRef = ref<HTMLDivElement | null>(null);
  const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
  onMounted(() => {
    const data = props.overviewData;
    setOptions({
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          lineStyle: {
            width: 1,
            color: '#019680',
          },
        },
      },
      grid: { left: '1%', right: '1%', top: '10', bottom: 0, containLabel: true },
      xAxis: {
        type: 'category',

        data: data?.useStateNameList,
      },
      yAxis: {
        type: 'value',

        splitNumber: 4,
      },
      series: {
        type: 'bar',
        barMaxWidth: 60,
        data: data?.useStateCountList,
      },
    });
  });
</script>
